//
// Created by Administrator on 25-6-27.
//
#include "SE_HW.h"

void SE_Init(SEOBJ* se) {
    se->TIMx->ARR = 19999;
    se->TIMx->PSC = 79;
}

void SE_SetStatus(SEOBJ *se, uint8_t status) {
    if (status == SEOFF) {
        HAL_TIM_PWM_Stop(se->HTIMx, se->TIMCHx);
    }else {
        HAL_TIM_PWM_Start(se->HTIMx, se->TIMCHx);
    }
}

void SE_Rotate(struct SE *se, uint8_t r) {
    uint32_t rot = r;
    switch (se->TIMCHx) {
        case TIM_CHANNEL_1:
            se->TIMx->CCR1 = SERPWM(20999,rot);
            break;
        case TIM_CHANNEL_2:
            se->TIMx->CCR2 = SERPWM(20999,rot);
            break;
        case TIM_CHANNEL_3:
            se->TIMx->CCR3 = SERPWM(20999,rot);
            break;
        case TIM_CHANNEL_4:
            se->TIMx->CCR4 = SERPWM(20999,rot);
            break;
    }
}
